package wangjg.coco.views;

import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
import org.eclipse.ui.internal.WorkbenchImages;

import wangjg.coco.Activator;

public class ExplorerPreferencePage extends FieldEditorPreferencePage
		implements IWorkbenchPreferencePage {
	public static final String CMD = "wangjg.coco.views.ExplorerPreferencePage.cmd";
	public static final String IF_USE_CMD = "wangjg.coco.views.ExplorerPreferencePage.IF_USE_CMD";
	//模型附加处理器路径
	public static final String GEN_CONFIG = "wangjg.coco.views.ExplorerPreferencePage.GEN_CONFIG";
	//codeParser
	public static final String CODE_PARSER = "wangjg.coco.views.ExplorerPreferencePage.CODE_PARSER";

	public ExplorerPreferencePage() {
		super(GRID);
		setTitle("Password Policy");
		ImageDescriptor imgDes = WorkbenchImages.getImageDescriptor(IWorkbenchGraphicConstants.IMG_DTOOL_NEW_FASTVIEW);
		setImageDescriptor(imgDes);
		setPreferenceStore(Activator.getDefault().getPreferenceStore());
	}

	public void init(IWorkbench workbench) {
	}

	protected void createFieldEditors() {
		addField(new StringFieldEditor(CMD, "命令行", getFieldEditorParent()));
		addField(new BooleanFieldEditor(IF_USE_CMD, "是否使用命令行打开", getFieldEditorParent()));
		//addField(new ComboFieldEditor(IF_USE_CMD, "是否使用命令行打开", new String[][]{{"自动","AUTO"},{"是","YES"},{"否","NO"}}, getFieldEditorParent()));
		
		addField(new StringFieldEditor(GEN_CONFIG, "gconf", getFieldEditorParent()));
		
		addField(new StringFieldEditor(CODE_PARSER, "parser", getFieldEditorParent()));
		
	}
	
	public static boolean useCmd(){
		return Activator.getDefault().getPreferenceStore().getBoolean(IF_USE_CMD);
	}

	public static String getCmd(){
		return Activator.getDefault().getPreferenceStore().getString(CMD);
	}

	public static String getGenConf(){
		return Activator.getDefault().getPreferenceStore().getString(GEN_CONFIG);
	}

	public static String getCodeParser(){
		return Activator.getDefault().getPreferenceStore().getString(CODE_PARSER);
	}
}
